const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('act_ru_timer_job', {
    id: {
      type: DataTypes.STRING(64),
      allowNull: false,
      primaryKey: true,
      field: 'ID_'
    },
    rev: {
      type: DataTypes.INTEGER,
      allowNull: true,
      field: 'REV_'
    },
    type: {
      type: DataTypes.STRING(255),
      allowNull: false,
      field: 'TYPE_'
    },
    lockExpTime: {
      type: DataTypes.DATE(3),
      allowNull: true,
      field: 'LOCK_EXP_TIME_'
    },
    lockOwner: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'LOCK_OWNER_'
    },
    exclusive: {
      type: DataTypes.BOOLEAN,
      allowNull: true,
      field: 'EXCLUSIVE_'
    },
    executionId: {
      type: DataTypes.STRING(64),
      allowNull: true,
      references: {
        model: 'act_ru_execution',
        key: 'id_'
      },
      field: 'EXECUTION_ID_'
    },
    processInstanceId: {
      type: DataTypes.STRING(64),
      allowNull: true,
      references: {
        model: 'act_ru_execution',
        key: 'id_'
      },
      field: 'PROCESS_INSTANCE_ID_'
    },
    procDefId: {
      type: DataTypes.STRING(64),
      allowNull: true,
      references: {
        model: 'act_re_procdef',
        key: 'id_'
      },
      field: 'PROC_DEF_ID_'
    },
    elementId: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'ELEMENT_ID_'
    },
    elementName: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'ELEMENT_NAME_'
    },
    scopeId: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'SCOPE_ID_'
    },
    subScopeId: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'SUB_SCOPE_ID_'
    },
    scopeType: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'SCOPE_TYPE_'
    },
    scopeDefinitionId: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'SCOPE_DEFINITION_ID_'
    },
    retries: {
      type: DataTypes.INTEGER,
      allowNull: true,
      field: 'RETRIES_'
    },
    exceptionStackId: {
      type: DataTypes.STRING(64),
      allowNull: true,
      references: {
        model: 'act_ge_bytearray',
        key: 'id_'
      },
      field: 'EXCEPTION_STACK_ID_'
    },
    exceptionMsg: {
      type: DataTypes.STRING(4000),
      allowNull: true,
      field: 'EXCEPTION_MSG_'
    },
    duedate: {
      type: DataTypes.DATE(3),
      allowNull: true,
      field: 'DUEDATE_'
    },
    repeat: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'REPEAT_'
    },
    handlerType: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'HANDLER_TYPE_'
    },
    handlerCfg: {
      type: DataTypes.STRING(4000),
      allowNull: true,
      field: 'HANDLER_CFG_'
    },
    customValuesId: {
      type: DataTypes.STRING(64),
      allowNull: true,
      references: {
        model: 'act_ge_bytearray',
        key: 'id_'
      },
      field: 'CUSTOM_VALUES_ID_'
    },
    createTime: {
      type: DataTypes.DATE(3),
      allowNull: true,
      field: 'CREATE_TIME_'
    },
    tenantId: {
      type: DataTypes.STRING(255),
      allowNull: true,
      defaultValue: "",
      field: 'TENANT_ID_'
    }
  }, {
    sequelize,
    tableName: 'act_ru_timer_job',
    timestamps: false,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "ID_" },
        ]
      },
      {
        name: "ACT_IDX_TIMER_JOB_EXCEPTION_STACK_ID",
        using: "BTREE",
        fields: [
          { name: "EXCEPTION_STACK_ID_" },
        ]
      },
      {
        name: "ACT_IDX_TIMER_JOB_CUSTOM_VALUES_ID",
        using: "BTREE",
        fields: [
          { name: "CUSTOM_VALUES_ID_" },
        ]
      },
      {
        name: "ACT_IDX_TJOB_SCOPE",
        using: "BTREE",
        fields: [
          { name: "SCOPE_ID_" },
          { name: "SCOPE_TYPE_" },
        ]
      },
      {
        name: "ACT_IDX_TJOB_SUB_SCOPE",
        using: "BTREE",
        fields: [
          { name: "SUB_SCOPE_ID_" },
          { name: "SCOPE_TYPE_" },
        ]
      },
      {
        name: "ACT_IDX_TJOB_SCOPE_DEF",
        using: "BTREE",
        fields: [
          { name: "SCOPE_DEFINITION_ID_" },
          { name: "SCOPE_TYPE_" },
        ]
      },
      {
        name: "ACT_FK_TIMER_JOB_EXECUTION",
        using: "BTREE",
        fields: [
          { name: "EXECUTION_ID_" },
        ]
      },
      {
        name: "ACT_FK_TIMER_JOB_PROCESS_INSTANCE",
        using: "BTREE",
        fields: [
          { name: "PROCESS_INSTANCE_ID_" },
        ]
      },
      {
        name: "ACT_FK_TIMER_JOB_PROC_DEF",
        using: "BTREE",
        fields: [
          { name: "PROC_DEF_ID_" },
        ]
      },
    ]
  });
};
